<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2006/04/11 20:58:15 $)
// $RCSfile: knowledgebase.php,v $ : $Revision: 1.14 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================

if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

define("ARTICLE_PUBLISHED", "published");
define("ARTICLE_DRAFT", "draft");
define("ARTICLE_PRIVATE", "private");

/**
* Knowledgebase Module
*/
class knowledgebase {

	/**
	* Constructor to register any events, sections
	*/
	function knowledgebase() {
		global $_SWIFT, $events;

		$events->registerEventModuleSWIFT(MODULE_KNOWLEDGEBASE, $this);

		// Staff CP
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "managecategories");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "insertcategory");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "editcategory");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "managequestions");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "insertquestion");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "editquestion");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "importexport");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "comments");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "ajax");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "reports");
		$events->registerEvent(EVENT_STAFF, MODULE_KNOWLEDGEBASE, "preview");

		// Client Area
		$events->registerEvent(EVENT_CLIENT, MODULE_KNOWLEDGEBASE, "view");
		$events->registerEvent(EVENT_CLIENT, MODULE_KNOWLEDGEBASE, "viewarticle");
		$events->registerEvent(EVENT_CLIENT, MODULE_KNOWLEDGEBASE, "pdfexport");
		$events->registerEvent(EVENT_CLIENT, MODULE_KNOWLEDGEBASE, "printable");
		$events->registerEvent(EVENT_CLIENT, MODULE_KNOWLEDGEBASE, "emailarticle");
		$events->registerEvent(EVENT_CLIENT, MODULE_KNOWLEDGEBASE, "ratearticle");
		$events->registerEvent(EVENT_CLIENT, MODULE_KNOWLEDGEBASE, "irsfetch");

		// RSS
		$events->registerEvent(EVENT_RSS, MODULE_KNOWLEDGEBASE, "view");

		$eventaction = $events->eventdata["eventaction"];
	}

	/**
	* Destructor, called to unregister any events etc
	*/
	function _knowledgebase() {
	}

	/*
	* Call back function
	*/
	function _eventcallback($eventtype, $eventaction)
	{
		global $_SWIFT, $interface, $template, $departments, $staffauth, $module, $grid, $xml, $staff, $settings, $dbCore, $events, $session, $loginshare, $cookie, $errormessage, $infomessage, $permissions, $mimelist;

		if ($eventtype == EVENT_STAFF && ($eventaction == "managecategories" || $eventaction == "insertcategory" || $eventaction == "editcategory")) {
			require_once ("./modules/knowledgebase/staff_categories.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "managequestions" || $eventaction == "insertquestion" || $eventaction == "editquestion")) {
			require_once ("./modules/knowledgebase/staff_questions.php");
			return true;
		} else if ($eventtype == EVENT_CLIENT && ($eventaction == "view" || $eventaction == "viewarticle" || $eventaction == "printable" || $eventaction == "pdfexport" || $eventaction == "ratearticle")) {
			require_once ("./modules/knowledgebase/client_knowledgebase.php");
			return true;
		} else if ($eventtype == EVENT_CLIENT && ($eventaction == "irsfetch")) {
			require_once ("./modules/knowledgebase/client_irs.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "ajax")) {
			require_once ("./modules/knowledgebase/staff_ajax.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "reports")) {
			require_once ("./modules/knowledgebase/staff_reports.php");
			return true;
		} else if ($eventtype == EVENT_RSS && ($eventaction == "view")) {
			require_once ("./modules/knowledgebase/rss_view.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "importexport" || $eventaction == "reports" || $eventaction == "preview")) {
			require_once ("./modules/knowledgebase/staff_misc.php");
			return true;
		} else if ($eventtype == EVENT_STAFF && ($eventaction == "comments")) {
			require_once ("./modules/knowledgebase/staff_comments.php");
			return true;
		} else if ($eventtype == EVENT_CLIENT && ($eventaction == "emailarticle")) {
			require_once ("./modules/knowledgebase/client_emailarticle.php");
			return true;
		}

		return false;
	}
}
?>